<template>
  <el-container class="home-container">
    <el-header>
      <router-link style="text-decoration: none;" to="/home">
        <div class="logo_tile">
          <h2>10组报价系统-客户</h2>
        </div>
      </router-link>
      <div class="logo_tile">
        <span> 欢迎：<i class="el-icon-arrow-left"></i>{{loginUser}}<i class="el-icon-arrow-right"></i> </span>
        <el-button @click="logout" type="info">退出</el-button>
      </div>
    </el-header>
    <el-container>
      <el-main>
        <el-card class="box-card">
          <el-dropdown>
                <span class="el-dropdown-link">
                    我的订单<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item ><a @click="myOrder">未支付</a></el-dropdown-item>
              <el-dropdown-item ><a @click="ispay">已支付</a></el-dropdown-item>
              <el-dropdown-item ><a @click="okpay">已转合同</a></el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <el-dropdown>
                <span class="el-dropdown-link">
                    发票管理<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item ><a @click="billList()">发票列表</a></el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>

        </el-card>
        <br>
        <div>
          <router-view></router-view>
        </div>
      </el-main>
    </el-container>
    <span style="color: gray; position: fixed; bottom: 0; right: 0;">10组报价系统</span>
  </el-container>
</template>

<script>
  export default {
    name: "Home",
    data() {
      return {
        loginUser:'XXX'
      }
    },
    methods:{
      logout:function () {
        sessionStorage.removeItem("user");//退出之前先清除sessionStorage中user信息
        this.$router.push('/login') //退出到登录页
      },
      myOrder:function () {//未付款
        this.$router.push({path:'/myorder',query:{id:3,loginUser:this.loginUser}})
      },
      ispay:function () {//已付款
        this.$router.push({path:'/isorder',query:{id:4,loginUser:this.loginUser}})
      },
      okpay:function () {//已转合同
        this.$router.push({path:'/okorder',query:{id:5,loginUser:this.loginUser}})
      },
      bill:function () {//发票申请
        this.$router.push({path:'/billAdd'})
      },
      billList:function () {//发票列表
        this.$router.push({path:'/billList'})
      },
    },
    mounted() {
      //获取当前登录用户
      let costomer=JSON.parse(sessionStorage.getItem("costomer")); //=JSON.parse()字符串转json对象 ，JSON。stringify（）对象转字符串
       this.loginUser=costomer.name;
       let costomerId=costomer.id; //当前登录人id
      // this.getTreeByUserId(userId);
    }
  }
</script>

<style lang="less" scoped>
  .text {
     font-size: 14px;
   }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 1500px;
  }
  .home-container {
    height: 100%;
  }

  .el-header {
    background-color: #373d41;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    user-select: none;

    .logo_tile {
      display: flex;
      align-items: center;
      color: white;

      h2 {
        font-weight: 200;
        margin-left: 15px;
      }
    }

    .el-button {
      margin-right: 10px;
    }
  }

  .el-aside {
    background-color: #333744;
    user-select: none;
  }

  .el-main {
    background-color: #eaedf1;
  }

  .iconfont {
    margin-right: 8px;
  }

  .toggleBar {
    color: #fff;
    font-size: 12px;
    line-height: 24px;
    background-color: #4a5064;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
    user-select: none;
  }

  .el_submenu_large {
    width: 200px;
  }

  .el_submenu_small {
    width: 65px;
  }
</style>
